//
// Created by Administrator on 2025/8/22.
//

#ifndef CPP_STRBLOB_H
#define CPP_STRBLOB_H
// 12章
#include <memory>
#include <string>
#include <vector>

class StrBlobPtr;
class StrBlob
{
    friend class StrBlobPtr;
    friend std::ostream &operator<<(std::ostream &os, const StrBlob &b1);
public:
    typedef std::vector<std::string>::size_type size_type;
    StrBlob();
    StrBlob(std::initializer_list<std::string> il);
    std::string& operator[](size_type n);
    const std::string &operator[](size_type n) const;
    size_type size() const { return data->size(); }
    bool empty() const { return data->empty(); }

    void push_back(const std::string& s) { data->push_back(s); }
    void push_back(std::string &&s) { data->push_back(std::move(s)); }
    void pop_back();

    std::string& front();
    std::string& back();
    const std::string& front() const;
    const std::string& back() const;

    void check(size_type i, const std::string& msg) const;



    StrBlobPtr begin();

    StrBlobPtr end();
private:
    std::shared_ptr<std::vector<std::string>> data;
};
#endif //CPP_STRBLOB_H
